<?php
/**
 * 功能描述：	会员模块
 * @datetime	2020-05-04
 * @version   	v1.0
 * @author   	ZHL
 * @copyrigh  	2020 ZHL 版权所有
 */

class Web_MemberController extends Controller {

    // 是否登录
    function __construct($controller, $action) {
        parent::__construct($controller, $action);
        $loginSer = new Web_LoginServe();
        $loginSer->judgeSessionLogin(1);
    }

    // 个人中心
    function index() {
        $memberSer = new Web_MemberServe();
        $member_info = SYS_SESSIONS_GET('member_info');
        if(!isset($member_info['id'])){
            $url = SYS_HOST.'login.html';
            htmlAlert('超时！请重新登录',$url,3,1);
        }
        $id = $member_info['id'];
        $where['id'] = $id;
        $info = $memberSer->getMemberInfo($where);
        $this->set('member', $info);
        $this->display('web_member/index');
    }

    /**
     * Notes:修改用户信息
     */
    public function update(){
        $sub_flag = Fun::input('sub_flag');
        $param['title'] = Fun::input('user_name');
        $param['pwd'] = Fun::input('user_pwd');
        $param['pwd2'] = Fun::input('user_pwd2');
        $param['code'] = Fun::input('verifycode');
        if($sub_flag){
            $memberSer = new Web_MemberServe();
            $result = $memberSer->updateInfo($param);
            Fun::json($result, true);
        }
        $this->set('member', SYS_SESSIONS_GET('member_info'));
        $this->display('web_member/update');
    }

}